package com.jacky.service.impl;

import com.jacky.po.AbstractUser;
import com.jacky.po.Admin;
import com.jacky.po.Customer;
import com.jacky.service.IdentifyService;

import java.util.Scanner;

/**
 * @Description: 选择身份的接口实现类
 * @author: Jacky
 * @date: 2021.10.13
 */
public class IdentifyServiceImpl implements IdentifyService {
    @Override
    public AbstractUser identifyForLogin(String userName,String password,String identity) {
        Scanner input = new Scanner(System.in);
        switch (identity){
            case "1":
                identity = "Admin";
                AbstractUser adminUser = new Admin(userName,password,identity);
                return adminUser;
            case "2":
                identity = "Customer";
                AbstractUser customerUser = new Customer(userName,password,identity);
                return customerUser;
            default:
                System.out.println("输入错误");
                return null;
        }
    }

    @Override
    public AbstractUser identifyForRegister(String userName,String password,String identity) {
        switch (identity){
            case "1":
                identity = "Admin";
                AbstractUser adminUser = new Admin(userName,password,identity);
                return adminUser;
            case "2":
                identity = "Customer";
                AbstractUser customerUser = new Customer(userName,password,identity);
                return customerUser;
            default:
                System.out.println("输入错误");
                return null;
        }
    }
}
